package com.sky.controller.admin;

import com.sky.result.Result;
import com.sky.service.WorkspaceService;
import com.sky.vo.BusinessDataVO;
import com.sky.vo.DishOverViewVO;
import com.sky.vo.OrderOverViewVO;
import com.sky.vo.SetmealOverViewVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;

/**
 * 工作台相关接口
 */
@Api(tags = "工作台相关接口")
@RestController
@Slf4j
@RequestMapping("/admin/workspace")
public class WorkspaceController {

    @Autowired
    private WorkspaceService workspaceService ;

    /**
     * 获取工作台今日数据
     * @return
     */
    @ApiOperation("获取工作台今日数据")
    @GetMapping("/businessData")
    public Result<BusinessDataVO> getBusinessData() {
        log.info("获取工作台今日数据...");
        //获取当日日期
        LocalDate today = LocalDate.now();

        //计算当日的开始日期和结束日期
        LocalDateTime beginTime = LocalDateTime.of(today, LocalTime.MIN);
        LocalDateTime endTime = LocalDateTime.of(today, LocalTime.MAX);
        BusinessDataVO businessDataVO = workspaceService.getBusinessData(beginTime, endTime) ;
        return Result.success(businessDataVO) ;
    }

    /**
     * 工作台套餐信息统计
     * @return
     */
    @ApiOperation("工作台套餐信息统计")
    @GetMapping("/overviewSetmeals")
    public Result<SetmealOverViewVO> getSetmealOverView() {
        log.info("工作台套餐信息统计...");
        SetmealOverViewVO setmealOverViewVO = workspaceService.getSetmealOverView() ;
        return Result.success(setmealOverViewVO) ;
    }

    /**
     * 工作台菜品信息统计
     * @return
     */
    @ApiOperation("工作台菜品信息统计")
    @GetMapping("/overviewDishes")
    public Result<DishOverViewVO> getDishOverView() {
        log.info("工作台菜品信息统计...");
        DishOverViewVO dishOverViewVO = workspaceService.getDishOverView() ;
        return Result.success(dishOverViewVO) ;
    }

    /**
     * 工作台订单管理信息统计
     * @return
     */
    @ApiOperation("工作台订单管理信息统计")
    @GetMapping("/overviewOrders")
    public Result<OrderOverViewVO> getOrderOverView() {
        log.info("工作台订单管理信息统计...");
        OrderOverViewVO orderOverViewVO = workspaceService.getOrderOverView() ;
        return Result.success(orderOverViewVO) ;
    }

}
